1. Technical Field
The present invention is directed generally to data processing systems and, in particular, to synchronizing commands. Still more particularly, the present disclosure relates to a method and apparatus for synchronizing commands to prevent data corruption.
2. Description of the Related Art
Data processing systems typically copy data from a permanent storage location into cache memory prior to performing an operation on the data, such as a read or a write operation. Data is copied into cache so that future requests for that data can be served faster. In data processing systems supporting multiple threads of execution, there is a possibility that data in the same memory region in cache may be accessed simultaneously by different processes. When one process updates or otherwise alters the data in cache, any other processes reading or writing to that same data region may be working on an out-of-date, invalid, or corrupted copy of the data.
A locking mechanism may be utilized for storage processors to provide for execution of host commands to the same region of memory in order to prevent data corruption. A lock is a synchronization mechanism for limiting access to the same region of memory. A read lock may be used to prevent writes to a particular region of memory. Likewise, a write lock may be used to prevent other processes from reading the region of memory while changes are being made to the region of memory.
Most locking mechanisms construct elaborate structures to expedite locking and unlocking regions of storage that have multiple outstanding read commands and/or write commands. For example, locking mechanisms may utilize Adelson-Velskii (AVL) trees, sequencing commands, and bit maps. These locking mechanisms require searching of outstanding commands in order to keep the bit maps correct, parsing of still pending commands to reset the lock mask, and/or re-balancing AVL trees and other complicated structures that require multiple steps to reset the locks.
Therefore, it would be advantageous to have a method and apparatus that takes into account one or more of the issues discussed above, as well as possibly other issues.